package cn.fxc;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Util {
    public static double[] loadData() {
        try {
            File inputFile = new File("datas3.txt");
            InputStreamReader fileInputStream = new InputStreamReader(new FileInputStream(inputFile));
            BufferedReader bufferedReader = new BufferedReader(fileInputStream);
            List<Double> datas = new ArrayList<>();
            String str;
            while ((str = bufferedReader.readLine()) != null) {
                try {
                    Double d = Double.parseDouble(str);
                    datas.add(d);
                } catch (NumberFormatException e) {
                    throw new RuntimeException(e);
                }
            }
            double[] array = new double[datas.size()];
            for (int s = 0; s < datas.size(); s++) {
                array[s] = datas.get(s);
            }
            return array;
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
